Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI warmup auto #2886

Closed
wants to merge 78 commits into from
Closed

MPI warmup auto #2886

wants to merge 78 commits into from

Conversation

bbbales2
Copy link
Member

Submission Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

This pulls in the auto metric from: #2815

How to Verify

This is part of: stan-dev/cmdstan#821

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Columbia University

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

bbbales2 and others added 30 commits April 18, 2019 11:22
so that cmdstan has access to the parameter
@bbbales2 bbbales2 requested a review from yizhang-yiz February 18, 2020 18:32
@bbbales2 bbbales2 changed the title Mpi warmup auto MPI warmup auto Feb 18, 2020
@@ -214,120 +215,6 @@ namespace mcmc {
logger.info(message);
}

/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the old v1? It helps when I go back do specific sampler testing. All I need to do then is to switch the sampler call.

~adapt_auto_e_nuts() {}

sample
transition(sample& init_sample, callbacks::logger& logger) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the call to mpi adapter, see

if (this -> use_cross_chain_adapt()) {
. Its logic is easier to understand. It also makes single chain default back to regular warmup.


if (update) {
//std::cout << this->z_.inv_e_metric_ << std::endl;
this->z_.is_diagonal_ = reinterpret_cast<mpi_auto_adaptation<Model> *>(this->var_adapt)->is_diagonal_;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use CRTP to access things like z_. If this is only for MPI you can put it inside var_adapt's learn_metric virtual function. Just want to explain how it's done in other samplers, not something you have to do at this point, since the code is still evolving.

template <typename Model>
class mpi_auto_adaptation : public mpi_metric_adaptation {
#ifdef STAN_LANG_MPI
using est_t = stan::math::mpi::mpi_covar_estimator;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the dense_e 's covar calculation and no longer use the naive version of mpi_covar_estimator. It's intended to improve communication performance. It's ok for you to use the old version.

@@ -38,6 +39,11 @@ namespace util {
static const bool value = true;
};

template <class Model, class RNG>
struct has_cross_chain_warmup<mcmc::adapt_auto_e_nuts<Model, RNG>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed.

@@ -141,9 +147,9 @@ namespace util {
using stan::math::mpi::Session;
using stan::math::mpi::Communicator;

if (Session::is_in_inter_chain_comm(num_chains)) {
if (file_name.size() > 0 && num_chains > 1 && Session::is_in_inter_chain_comm(num_chains)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed

const Communicator& comm = Session::inter_chain_comm(num_chains);
file_name = "mpi." + std::to_string(comm.rank()) + "." + file_name;
file_name = file_name + "." + "mpi." + std::to_string(comm.rank());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file_name could be output.csv so you'll be looking at output.csv.mpi.1.

Copy link

@yizhang-yiz yizhang-yiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comments. Since we were doing it the same time some things here are no longer needed. In particular, v2 already supports degenerating to regular chain when only one MPI proc is supplied.

@yizhang-yiz yizhang-yiz force-pushed the mpi_warmup_v2 branch 3 times, most recently from a7c61ac to 405266d Compare February 24, 2020 19:54
@bbbales2
Copy link
Member Author

This can close. @yizhang-yiz probably has a more up to date implementation of this elsewhere.

@bbbales2 bbbales2 closed this Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants